import axiosIns from '@/plugins/axios';

export function approveVisitRecord(id: number) {
  return axiosIns.post('/api/visit-record/approve', { id });
}

export function rejectVisitRecord(id: number, appointment_id: number) {
  return axiosIns.post('/api/visit-record/reject', { id, appointment_id });
}

export function getConsultVisitRecords() {
  return axiosIns.get('/api/visit-record/consult');
}

export function updateAppointmentArrangement(appointment_id: number, scheduled_time: string, scheduled_place: string, consultant_id?: number) {
  const data: any = {
    id: appointment_id,
    scheduled_time,
    scheduled_place
  };
  if (consultant_id) {
    data.consultant_id = consultant_id;
  }
  return axiosIns.post('/api/appointment/update-arrangement', data);
}

// 获取指定预约时间可用的咨询师值班安排
export function getAvailableDutySchedules(appointmentTime: string) {
  const params: any = { appointmentTime, role: 'CONSULTANT' };
  return axiosIns.get('/api/duty/available', { params });
}

// 获取所有咨询师的值班安排
export function getConsultantDutySchedules() {
  return axiosIns.get('/api/duty/consultants');
}

// 获取指定日期的值班安排
export function getDutySchedulesByDate(date: string, role?: string) {
  const params: any = { date };
  if (role) {
    params.role = role;
  }
  return axiosIns.get('/api/duty/by-date', { params });
} 